<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>添加学生</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
    <style>
        .w440{
            width: 440px !important;
        }
    </style>
</head>
<body>
<div class="wrap-container clearfix">
    <div class="column-content-detail">
        <form class="layui-form" method="post" action="/work/asset/exportWarranty">
            <div class="tab-step-ctn mart20">
                <div class="tab-step-line ">
                    <span class="circle">1</span>
                    <div class="tab-step-name">基础信息填写</div>
                    <i class="iconfont">&#xe688;</i>
                </div>
                <div class="tab-step-line checked">
                    <span class="circle">2</span>
                    <div class="tab-step-name">添加考生</div>
                    <i class="iconfont">&#xe688;</i>
                </div>
                <div class="tab-step-line">
                    <span class="circle">3</span>
                    <div class="tab-step-name">考场分配</div>
                    <i class="iconfont">&#xe688;</i>
                </div>
                <div class="tab-step-line">
                    <span class="circle">4</span>
                    <div class="tab-step-name">监、巡考老师设置</div>
                    <i class="iconfont">&#xe688;</i>
                </div>
                <div class="tab-step-line">
                    <span class="circle">5</span>
                    <div class="tab-step-name">发布考试通知</div>
                    <i class="iconfont">&#xe688;</i>
                </div>
            </div>
            <div class="search-cont clearfix" id="tool">
                <div class="operation-btn-cont">
                    <div class="operright cyt-retract-close hideMenu"> 收起筛选<i class="iconfont">&#xe658;</i></div>
                    <div class="operright cyt-retract-open showMenu" style="display: none;"> 展开筛选<i class="iconfont">&#xe936;</i></div>
                    <!--button开始-->
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="selectFile"><i class="iconfont marr5">&#xe606;</i>导入考生</button>
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="exportExcel"><i class="iconfont marr5">&#xe606;</i>下载模板</button>


                    <!--button结束-->
                    <div class="triangle-bottom"></div>
                    <div class="triangle-top"></div>
                </div>
                <div class="search-details">
                    <div class="layui-form-item marb5">
                        <!--search开始-->
                        <div class="layui-inline">
                            <label class="layui-form-label">姓名：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" id="name" placeholder="请输入姓名" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">学号：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="userNumber" id="userNumber" placeholder="请输入学号" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">登录名：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="loginName" id="loginName" placeholder="登录名" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <!--search结束-->
                        <div class="layui-inline marl8">
                            <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="seacherBtn">搜索</button>
                            <button class="layui-btn layui-btn-normal" type="reset">重置</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <div class="layui-form" id="table-list">
            <table id="entityList" lay-filter="entityList" class="cy-list-table"></table>
        </div>
        <div class="layui-form-item ">
            <div class="layui-input-block" style="margin-left: 0px !important;text-align: center; margin-top: 30px !important;">
                <button class="layui-btn layui-btn-normal wxyy-tab-btn" id="frontStep">上一步</button>
                <button class="layui-btn layui-btn-normal wxyy-tab-btn" id="nextStep">下一步</button>
                <button type="button" id="cancel" class="layui-btn layui-btn-primary wxyy-tab-btn">取消</button>

            </div>
        </div>
    </div>
</div>

<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    var tableIns = null;
    var applyId='${applyId}';
    var baseutil = null;
    var ksId = '${ksId}';
    var studentNumber ="";
    var menuId='${parentMenuId}';
    layui.use(['jquery', 'table', 'page', 'dialog','upload','baseutil'], function () {
        var $ = layui.jquery,
            page = layui.page,
            table = layui.table,
            upload = layui.upload,
            dialog = layui.dialog;
            baseutil = layui.baseutil;

        //更新当前用户步骤
        baseutil.post('/work/kwmanagement/kwmanagement/addOrUpdateStop', {"step": "2","id":ksId}, function (result) {
            if (0 == result.code) {
            }
        });
        //获取分页数据
            var url = "/work/kwmanagement/kwstudentmessage/page?ksId="+ksId+"&applyId="+applyId;
            var cols = [
                {field: 'title', title: '序号', align: 'left', width:80,type:'numbers'},
                {field: 'name', title: '姓名', align: 'center'},
                {field: 'userNumber', title: '学号', align: 'center'},
                {field: 'loginName', title: '登录名', align: 'center'},
                {field: 'mobile', title: '手机号', align: 'center'}
            ];
            tableIns = page.initDate(cols, url);

        upload.render({
            elem: '#selectFile'
            ,url: '/work/kwmanagement/kwstudentmessage/importExcel'
            , accept: 'file'
            , data: {ksId:ksId,applyId:applyId}
            , multiple: true
            , auto: true
            ,before:function(obj){
                layer.load();
            }
            ,done:function(res){
                curr=1;
                layer.closeAll('loading');
                if (res.code === 0) {
                    dialog.msg(res.msg);
                    studentNumber = res.data;
                    console.log(res.data);
                    tableIns = page.initDate(cols, url);

                } else {
                    dialog.msg(res.msg);
                }
            }
        });

        //监听行工具事件
        table.on('tool(entityList)', function (obj) {
            var layEvent = obj.event,
                data = obj.data;
            if(data!=""){
                studentNumber = data;
            }
        });

        //导出学生
        $("#exportExcel").on("click",function () {
            window.location.href = "/work/kwmanagement/kwstudentmessage/export";
        });

        //下一步
        $("#nextStep").click(function () {
            //获取学生数量的
            baseutil.post('/work/kwmanagement/kwstudentmessage/staticStudent', {"ksId":ksId,"applyId":applyId}, function (result) {
                if (0 == result.code) {
                    mStudentNum = result.data.length;
                   if(mStudentNum==0){
                       dialog.msg("请添加学生");
                   }else {
                       parent.tabRefresh(menuId);
                       page.edit("kwKcSettingEdit","/work/kwmanagement/kwKcSettingEdit?applyId="+applyId+"&ksId="+ksId+"&parentMenuId="+menuId,"设置考场");
                       parent.tabDelete('getNewEdit');
                       //刷新上一个界面的操作

                   }
                }else {
                    dialog.msg("请添加学生");
                }
            });

        });

        //上一步
        $("#frontStep").click(function () {
            page.edit("kwmangementEdit","/work/kwmanagement/kwmangementEdit?applyId="+applyId+"&ksId="+ksId+"&parentMenuId="+menuId,"基础信息");
            parent.tabDelete('getNewEdit');

        });

        //取消
        $("#cancel").click(function () {
            parent.tabDelete('getNewEdit');

        });

    });

</script>
</body>
</html>